package cn.com.zcode.user.control;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import cn.com.zcode.core.cache.ApplicationCacheInit;
import cn.com.zcode.core.control.ApplicationInitAware;
import cn.com.zcode.user.model.User;
import cn.com.zcode.user.service.UserService;

public class TestUserInit implements ApplicationInitAware {
	Logger logger = Logger.getLogger(ApplicationCacheInit.class);
	private UserService service;

	public void init(ApplicationContext context) {
		logger.info("初始化测试用户......开始");
		if(service.getUserByName("admin")==null){
			User user = new User("admin","daemon","admin");
			service.saveUser(user);
		}
		logger.info("初始化测试用户......完成");
	}

	public UserService getService() {
		return service;
	}

	public void setService(UserService service) {
		this.service = service;
	}

}
